ABC266 C - Convex Quadrilateral
https://atcoder.jp/contests/abc266/tasks/abc266_c
提出
code: python
s = list(map(int, input().split())) for _ in range(4)
a = s0
b = s1
c = s2
d = s3
# 角度 -> 傾き
ab = 0
if (s11 - s01) != 0:
ab = (s10 - s00) / (s11 - s01)
bc = 0
if (s21 - s11) != 0:
bc = (s20 - s10) / (s21 - s11)
cd = 0
if (s31 - s21) != 0:
cd = (30 - s20) / (s31 - s21)
da = 0
if (s01 - s31) != 0:
da = (00 - s30) / (s01 - s31)
print(ab, bc, cd, da)
解答
code: python
ax, ay = map(int, input().split())
bx, by = map(int, input().split())
cx, cy = map(int, input().split())
dx, dy = map(int, input().split())
def area(a, b, c):
ab = [b0 - a0, b1 - a1]
ac = [c0 - a0, c1 - a1]
return ab0 * ac1 - ab1 * ac0
# 各三角形の符号付き面積を求める
sign1 = area(ax, ay, bx, by, cx, cy)
sign2 = area(bx, by, cx, cy, dx, dy)
sign3 = area(cx, cy, dx, dy, ax, ay)
sign4 = area(dx, dy, ax, ay, bx, by)
if (sign1 < 0) == (sign2 < 0) == (sign3 < 0) == (sign4 < 0):
print("Yes")
else:
print("No")
メモ
https://atcoder.jp/contests/abc266/editorial/4659
ABC266 C問題 Convex Quadrilateral【C++, python】